#pragma once

#include <wx/wx.h>
#include <wx/thread.h>

typedef void* (*DAO_TASK_FUNC) (void* data);

class DaoTask : public wxThread {
public:
	DaoTask(DAO_TASK_FUNC task_func, void* data) {
		_task_func = task_func;
	}
    
    virtual ~DaoTask() {
    }

    virtual ExitCode Entry() {
    	return _task_func(_data);
    }

protected :
	DAO_TASK_FUNC _task_func;
	void* _data;
};


class TaskManager {
public:
	TaskManager();
    virtual ~TaskManager();

    static TaskManager& get() {
        if(_task_mgr==NULL) {
            _task_mgr = new TaskManager();
        }

        return *_task_mgr;
    }
    
    DaoTask* new_task(DAO_TASK_FUNC task_func, void* data) {
    	return new DaoTask(task_func, data);
    }

protected:
    static TaskManager* _task_mgr;
};

